/**
 * 
 */
package messaage;

/**
 * @author Olga
 *
 */
public class EditedPostMsg extends Message {

	private boolean isFriend;
	private String forumID;
	private String postID;
	private String date;
	private String newContent;
        
	/**
	 * 
	 */
	public EditedPostMsg(String msg) {
		this.parse(msg);
	}
	
	public EditedPostMsg(boolean isFriend, String forumID, String postID,
			String date, String newContent) {
		this.isFriend = isFriend;
		this.forumID = forumID;
		this.postID = postID;
		this.date = date;
		this.newContent = newContent;
	}

	@Override
	public String toString() {
		String ans = "";
		ans += this.isFriend + "\n";
		ans += this.forumID + "\n";
		ans += this.postID + "\n";
		ans += this.date + "\n";
		ans += this.newContent + "\n";
		return "EditedPost\n"+ans +"\0";
	}

	private void parse(String msg) {
		String[] info = msg.split("\n");
		this.isFriend = info[1].equals("true");
		this.forumID = info[2];
		this.postID = info[3];
		this.date = info[4];
		this.newContent = "";
		for (int i = 5; i < info.length; i++)
			if (i == info.length - 1)
				this.newContent += info[i];
			else
				this.newContent += info[i] + "\n";
	}

	/**
	 * @return the isFriend
	 */
	public boolean isFriend() {
		return isFriend;
	}

	/**
	 * @return the forumID
	 */
	public String getForumID() {
		return forumID;
	}

	/**
	 * @return the postID
	 */
	public String getPostID() {
		return postID;
	}

	/**
	 * @return the date
	 */
	public String getDate() {
		return date;
	}

	/**
	 * @return the newContent
	 */
	public String getNewContent() {
		return newContent;
	}
	
	

}
